package com.finger.forest;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.finger.forest.utils.ClickUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PatrolTypeActivity extends AppCompatActivity implements View.OnClickListener {

    /**
     * 返回
     */
    @BindView(R.id.btn_back)
    ImageView backIv;

    @BindView(R.id.patrol_type_1)
    TextView tv1;
    @BindView(R.id.patrol_type_2)
    TextView tv2;
    @BindView(R.id.patrol_type_3)
    TextView tv3;
    @BindView(R.id.patrol_type_4)
    TextView tv4;
    @BindView(R.id.patrol_type_5)
    TextView tv5;
    @BindView(R.id.patrol_type_6)
    TextView tv6;
    @BindView(R.id.patrol_type_7)
    TextView tv7;
    @BindView(R.id.patrol_type_8)
    TextView tv8;
    @BindView(R.id.patrol_type_9)
    TextView tv9;

    @BindView(R.id.btn_confirm)
    Button confirmBtn;

    private int patrolType = 1; //巡护类型
    private String patrolTypeName = ""; //巡护类型名称

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_patrol_type);
        ButterKnife.bind(this);

    }

    @OnClick({R.id.btn_back, R.id.btn_confirm, R.id.patrol_type_1, R.id.patrol_type_2, R.id.patrol_type_3, R.id.patrol_type_4,
            R.id.patrol_type_5, R.id.patrol_type_6, R.id.patrol_type_7, R.id.patrol_type_8, R.id.patrol_type_9})
    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            //返回
            case R.id.btn_back:
                finish();
                break;

            //确认
            case R.id.btn_confirm:
                //数据返回
                Intent intent = new Intent();
                intent.putExtra("patrolType", patrolType);
                intent.putExtra("patrolTypeName", patrolTypeName);
                //设置返回数据
                this.setResult(RESULT_OK, intent);
                this.finish();
                break;

            default: //选择巡护类型
                TextView textView = (TextView) v;
                tv1.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.radio_unselect, null), null, null, null);
                tv2.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.radio_unselect, null), null, null, null);
                tv3.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.radio_unselect, null), null, null, null);
                tv4.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.radio_unselect, null), null, null, null);
                tv5.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.radio_unselect, null), null, null, null);
                tv6.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.radio_unselect, null), null, null, null);
                tv7.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.radio_unselect, null), null, null, null);
                tv8.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.radio_unselect, null), null, null, null);
                tv9.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.radio_unselect, null), null, null, null);
                textView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.radio_select, null), null, null, null);
                patrolType = Integer.parseInt(textView.getTag().toString());
                patrolTypeName = textView.getText().toString();
                break;
        }

    }

}
